package com.weiweiqin.controller.home;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.weiweiqin.model.Feedback;
import com.weiweiqin.service.FeedbackService;
import com.weiweiqin.vo.common.Result;

@Controller
@RequestMapping("front/feedback")
public class FFeedbackController {

	@Autowired
	private FeedbackService feedbackService;

	private static final Logger logger = LoggerFactory
			.getLogger(FFeedbackController.class);

	@RequestMapping(value = "/add.do", method = { RequestMethod.POST,RequestMethod.GET })
	@ResponseBody
	public String add(Feedback feedback) {
		logger.info("Enter method add...,feedback="+feedback);
		Result result = new Result();
		try {
			feedbackService.save(feedback);
		} catch (Exception e) {
			logger.error("保存意见反馈异常...",e);
			result.setResult(false);
			result.setErrorMsg("保存意见反馈异常...");
			return result.toJson();
		}
		result.setResult(true);
		return result.toJson();
	}
}
